﻿using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

using Ajeelee.Core.Database;
using Ajeelee.Core.Utils;
using FxhjpgWeb.Business;
using FxhjpgWeb.Model;
using FxhjpgWeb.WebSite.Code;

namespace FxhjpgWeb.WebSite.WebAdmin
{
    public partial class JobList : AuthPageBase
    {
        protected string mname = "";
        protected int cateid;
        protected IList<Job> jobList = new List<Job>();
        protected IList<NewsClass> teamClassList = new List<NewsClass>();
        IJobBusiness jobBll = new JobBusinessFactory().CreateJobBusiness();
        PageStructure ps = new PageStructure() { PageSize = 15, CurrPage = 1 };

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            try
            {
                mname = QueryParam("mname");
                cateid = QueryParamInt32("cateid");
                ps.CurrPage = QueryParamInt32("page", 1);
                teamClassList = Utility.GetNewsClass().Where(c => c.PId == 12).ToList();

                // 删除
                if (!string.IsNullOrEmpty(QueryParam("d")) && QueryParamInt32("d") > 0)
                {
                    jobBll.Delete(QueryParamInt32("d"));
                }

                Hashtable ht = new Hashtable();
                if (cateid > 0)
                {
                    ht.Add(JobHash.Cid, cateid);
                }
                ht.Add(JobHash.Name, Function.SafeSqlLiteral(mname));
                jobList = jobBll.GetAllJobByPage(ht, ps);
                pager1.PageStruct = ps;
            }
            catch (Exception ex)
            {
                Function.WriteErrorLog(ex);
            }
        }
    }
}